package org.xinjiang.data.migration.flush.convert;

import org.mapstruct.Mapper;
import org.xinjiang.data.migration.common.mapstruct.CommonConvertConfig;
import org.xinjiang.data.migration.hainan.entity.HnRegionEntity;
import org.xinjiang.data.migration.xinjiang.entity.XjAreaEntity;

@Mapper(config = CommonConvertConfig.class)
public abstract class AreaFlushConvert {
    public XjAreaEntity convert(HnRegionEntity region) {
        XjAreaEntity area = new XjAreaEntity();
        area.setId(region.getId());
        area.setName(region.getName());
        area.setCode(region.getCode() == null ? "" : region.getCode());
        area.setPcode(region.getPcode() == null ? "" : region.getPcode());
        area.setAreaId(region.getAreaId() == null ? 0 : region.getAreaId());
        area.setLev(region.getLev());
        area.setAreaType(String.valueOf(region.getLev()));
        area.setCreateBy("admin");
        return area;
    }

}
